package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author jiyonghui
 * @className BatchSeqOperationEnum
 * @description
 * @date 2020/5/19   16:42
 */
@Getter
public enum BatchSeqOperationEnum {


    // 开启关闭批次号序列号
    ENABLEBATCH(1, "enum.batchSeqOperation.name.enableBatch", "enableBatch","enum.batchSeqOperation.saasName.enableBatch"),
    DISABLEBATCH(2, "enum.batchSeqOperation.name.disableBatch", "disableBatch", "enum.batchSeqOperation.saasName.disableBatch"),
    ENABLEGUARANTEEPERIOD(3, "enum.batchSeqOperation.name.enableGuaranteePeriod", "enableGuaranteePeriod", "enum.batchSeqOperation.saasName.enableGuaranteePeriod"),
    DISABLEGUARANTEEPERIOD(4, "enum.batchSeqOperation.name.disableGuaranteePeriod", "disableGuaranteePeriod", "enum.batchSeqOperation.saasName.disableGuaranteePeriod"),
    ENABLESEQ(5, "enum.batchSeqOperation.name.enableSeq", "enableSeq", "enum.batchSeqOperation.saasName.enableSeq"),
    DISABLESEQ(6, "enum.batchSeqOperation.name.disableSeq", "disableSeq","enum.batchSeqOperation.saasName.disableSeq"),

    ;

    private Integer code;
    private String name;
    private String attr;
    private String saasName;

    BatchSeqOperationEnum(Integer code, String name, String attr, String saasName) {
        this.code = code;
        this.name = name;
        this.attr = attr;
        this.saasName = saasName;
    }

    public static BatchSeqOperationEnum getByCode(Integer code) {
        for (BatchSeqOperationEnum cache : values()) {
            if (Objects.equals(code, cache.code)) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getSaasName() {
        return I18nMessageUtil.getMessage(saasName);
    }
}
